<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="page" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<link type="text/stylesheet" href="${page}/static/inspinia/js/plugins/LD.sot/multiupf/uploadify2/uploadify.css">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>INSPINIA | Basic Form</title>
    <script type="text/javascript" charset="utf-8" src="${ctx}/static/inspinia/js/plugins/ueditor-1.4.3.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${ctx}/static/inspinia/js/plugins/ueditor-1.4.3.3/_examples/editor_api.js"></script>
    <script type="text/javascript" charset="utf-8" src="${ctx}/static/inspinia/js/plugins/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js"></script>


    
    <style>
        .imager {
            margin: 0;
            padding: 0;
            width: 90px;
            height: 90px;
            float: left;
            background-color: #fff;
            text-align: center;
            vertical-align: middle;
            line-height: 81px;
            color: #000;
            border-radius: 4px;
        }

        .imager img {
            border-radius: 4px;
        }

        .upload {
            margin: 0;
            padding: 0;
            width: 83px;
            height: 31px;
            float: left;
            margin: 59px 0 0 11px;
        }
        .biref_words {
            color:red;
        }
        .marks_star{
            color:red;
        }
    </style>
</head>



<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row  m-t-sm">
            <div class="col-lg-12">
                <ol class="breadcrumb f-fl">
                    <li>
                        <i class="fa fa-location-arrow"></i> <a>资讯管理</a>
                    </li>
                    <li class="active">
                        <c:if test="${mhInfo.id != null}">
                            <strong>修改</strong>
                        </c:if>
                        <c:if test="${mhInfo.id == null || mhInfo.id == ''}">
                            <strong>新增</strong>
                        </c:if>
                    </li>
                </ol>
                <span class="navbar-right  m-r m-t-8"><a href="javascript:history.go(-1);" class="btn-primary btn-add "> <i class='fa fa-mail-reply'></i> 返回</a></span>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>注意： <small>请慎重修改.</small></h5>
                        </div>
                        <div class="ibox-content">
                            <form method="get" data-ajax="${ctx}/admin/info/list" action="${ctx}/admin/info/save"  class="form-horizontal" id="opt_form">
                                <input  type="hidden" name="id" value="${mhInfo.id}"/>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">列表图片</label>
                                    <div class="col-sm-1">
                                        <input  type="hidden" id="upImg480" name="image" value="${mhInfo.image}"/>
                                        <div class="imager" id="image" >
                                            <c:choose>
                                                <c:when test="${mhInfo.image!= null}">
                                                    <img src="${mhInfo.image}"  width="100%" height="100%">
                                                </c:when>
                                                <c:otherwise>
                                                    <img src="${ctx}/static/inspinia/img/default_pic_no.jpg"  width="100%" height="100%">
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="upload" id="uploader480"></div>
                                        <div class="tip upload-img-pt65"><span class="upload-img-ml6"></span>建议上传：320*480</div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">详细图片</label>
                                    <div class="col-sm-1">
                                        <input  type="hidden" id="upImg4801" name="detailpic" value="${mhInfo.detailpic}"/>
                                        <div class="imager" id="detailpic" >
                                            <c:choose>
                                                <c:when test="${mhInfo.detailpic!= null}">
                                                    <img src="${mhInfo.detailpic}"  width="100%" height="100%">
                                                </c:when>
                                                <c:otherwise>
                                                    <img src="${ctx}/static/inspinia/img/default_pic_no.jpg"  width="100%" height="100%">
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="upload" id="uploader4801"></div>
                                        <div class="tip upload-img-pt65"><span class="upload-img-ml6"></span>建议上传：320*480 </div>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label"><span class="text-danger">*</span>资讯标题</label>
                                    <div class="col-sm-8"><input type="text" name="title" placeholder="请输入标题" value="${mhInfo.title}" class="form-control" required></div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">类型</label>
                                    <div class="col-sm-6">
                                        <select name="hrefType" id="hrefType"  class=" form-control" items="${mhInfo.hrefType}" form="opt_form" style="width:20%" onchange="changeNewsType()">
                                            <option value="1" <c:if test="${mhInfo.hrefType=='1'}">selected="true"</c:if>>图文</option>
                                            <option value="2" <c:if test="${mhInfo.hrefType=='2'}">selected="true"</c:if>>内链</option>
                                            <option value="3" <c:if test="${mhInfo.hrefType=='3'}">selected="true"</c:if>>外链</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><span class="text-danger">*</span>资讯分类</label>
                                    <div class="col-sm-10">
                                        <select id="fl" name="classifyId"  class=" form-control" items="${mhInfo.classifyId}"  style="width:20%" required>
                                            <option value="">请选择分类</option>
                                            <c:forEach items="${cicn}" var="cicn" >
                                                <c:choose>
                                                    <c:when test="${cicn.id == mhInfo.classifyId}">
                                                        <option value="${cicn.id}" selected = "true">${cicn.title}</option>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <option value="${cicn.id}">${cicn.title}</option>
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:forEach>
                                        </select>
                                  <%--      <select id="fl2" name="classifyId"  class=" form-control" items="${mhInfo.classifyId}"  style="width:20%;display: none" required>

                                        </select>
                                        <span id="types" style="color: red"></span>--%>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><span class="text-danger">*</span>资讯来源</label>
                                    <div class="col-sm-10">
                                        <select id="ll" name="srcId"  class=" form-control" items="${mhInfo.srcId}"  style="width:20%" required>
                                            <option value="">请选择来源</option>
                                            <c:forEach items="${src}" var="src" >
                                                <c:choose>
                                                    <c:when test="${src.id == mhInfo.srcId}">
                                                        <option value="${src.id}" selected = "true">${src.title}</option>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <option value="${src.id}">${src.title}</option>
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>




                                <div class="form-group" id="urlDiv"><label class="col-sm-2 control-label">链接地址</label>
                                    <div class="col-sm-8"><input type="text" name="hrefUrl" placeholder="请输入链接地址" value="${mhInfo.hrefUrl}" class="form-control"></div>
                                </div>


                                <div class="form-group" id="newsdescDiv">
                                    <label class="col-sm-2 control-label">图文描述</label>
                                    <div class="col-sm-8"><textarea name="content" id="editor" type="text/plain" style="width:100%;height:444px;">${mhInfo.content}</textarea></div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-primary" type="submit" >保 存</button>
                                        <a href="javascript:history.go(-1);" class="btn btn-white ">  取消</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script type="text/javascript" src="${page}/static/inspinia/js/plugins/LD.sot/multiupf/uploadify2/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="${page}/static/inspinia/js/plugins/LD.sot/multiupf/uploadify2/swfobject.js"></script>
<script type="text/javascript" src="${page}/static/inspinia/js/plugins/LD.sot/multiupf/multiupf.uploadify2.js"></script>
<script>
    $(document).ready(function(a) {
        var ue = UE.getEditor('editor',{
            'enterTag':'',
            allowDivTransToP: false
        });
        changeNewsType();
    });

    $("#fl").trigger("click", secondClassify());
    //var sid = ${sid};
    function secondClassify() {
        var pid = $('#fl  option:selected').val();
        $.ajax({
            cache: true,
            type: "POST",
            url: '${ctx}/admin/info/second/classify',
            dataType: "json",
            data: {"id":pid},
            success: function (data) {
                if (data.success) {
                    var html = "";
                    var list = data.seclist;
                    for (var sec in list){
                        if(sid == list[sec].id) {
                            html += "<option value=\"" + list[sec].id + "\" selected = \"true\">" + list[sec].title + "</option>";
                        }else {
                            html += "<option value=\"" + list[sec].id + "\">" + list[sec].title + "</option>";
                        }
                    }
                    $("#fl2").html(html);
                    $("#fl2").show();
                    $("#fl").css('display','inline');
                    $("#fl2").css('display','inline');
                    $("#fl").attr('name','classifyId1');
                }else {
                    $("#fl2").hide();
                    $("#fl").css('display','inline');
                    $("#fl").attr('name','classifyId');
                }
                if (data.type == 1) {
                    $("#types").text("微信课堂");
                }else if(data.type == 2) {
                    $("#types").text("邻里中心");
                }else {
                    $("#types").text("");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }


    $(document).ready(function() {
        $("#uploader480").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader480') > -1) {
                    $("#imgUrl480").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader480') > -1) {
                    _id = '#image';
                    $('#upImg480').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });


        $("#uploader4801").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader4801') > -1) {
                    $("#imgUrl4801").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader4801') > -1) {
                    _id = '#detailpic';
                    $('#upImg4801').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });

        $("#uploader960").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader960') > -1) {
                    $("#imgUrl960").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader960') > -1) {
                    _id = '#imgUrl960';
                    $('#upImg960').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });

        $("#uploader1136").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader1136') > -1) {
                    $("#imgUrl1136").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader1136') > -1) {
                    _id = '#imgUrl1136';
                    $('#upImg1136').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });

        $("#uploader1334").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader1334') > -1) {
                    $("#imgUrl1334").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader1334') > -1) {
                    _id = '#imgUrl1334';
                    $('#upImg1334').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });

        $("#uploader1920").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader1920') > -1) {
                    $("#imgUrl1920").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader1920') > -1) {
                    _id = '#imgUrl1920';
                    $('#upImg1920').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });

        $("#uploader2208").multiupf({
            uploader: '${image_upload_url}',
            fileExts: '*.png;*.jpg;', fileDesc: '*.png;*.jpg;',
            progress: function (data, queue) {
                if (queue.indexOf('uploader2208') > -1) {
                    $("#imgUrl2208").html("上传中...");
                }
            },
            complete: function (result, queue) {
                var url = result.data[0];
                var _id = '';
                if (queue.indexOf('uploader2208') > -1) {
                    _id = '#imgUrl2208';
                    $('#upImg2208').val(url);
                }
                $(_id).css({
                    'background': 'url(' + url + ') no-repeat',
                    'background-size': '100% 100%'
                }).html('');
            }
        });


    });
    function changeNewsType(){
        var newsType = $("#hrefType").val();
        if(newsType == 1){
            $("#newsdescDiv").show();
            $("#urlDiv").hide();
        }else if(newsType == 2){
            $("#newsdescDiv").hide();
            $("#urlDiv").show();
        }else if(newsType == 3){
            $("#newsdescDiv").hide();
            $("#urlDiv").show();
        }
        else{
            $("#noteDiv").show();
            $("#urlDiv").show();
        }
    }

</script>
</body>

</html>
